package com.riven.bilibilidemo.application;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Process;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.riven.bilibilidemo.utils.HttpUtilsOne;

/**
 * @author rivenlee
 * @date 2017/2/21 20:03
 */

public class MyApplication extends Application {
    private static Context context;
    private static Handler handler;
    private static int mainThreadId;


    @Override
    public void onCreate() {
        super.onCreate();
        HttpUtilsOne.getInstanc();
        //获取应用的上下文
        context = getApplicationContext();
        //handler线程
        handler = new Handler();
        //获取主线程的线程号
        mainThreadId = Process.myTid();
        ImageLoaderConfiguration configuration = ImageLoaderConfiguration
                .createDefault(this);

        //Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(configuration);
    }

    /**
     * 获取上下文
     */
    public static Context getContext() {
        return context;
    }

    /**
     * 获取Handler对象
     */
    public static Handler getHandler() {
        return handler;
    }

    /**
     * 获取主线程号
     */
    public static int getMainThreadId() {
        return mainThreadId;
    }

    /**
     * 获取主线程
     */
    public static Thread getMainThread() {
        return Thread.currentThread();
    }


}
